FROM ghcr.io/gem5/ubuntu-24.04_all-dependencies:latest

ARG DEBIAN_FRONTEND=noninteractive
ARG TZ_ARG=UTC
ENV TZ=${TZ_ARG}

# 更新并安装基础工具
# 安装依赖（使用清华/阿里云 apt 源）
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    apt -y update && apt -y upgrade && apt install -y \
    tzdata \
    locales \
    curl \
    python3 \
    python3-pip \
    tmux \
    wget \
    tree \
    vim \
    bc \
    git && \
    # 设置时区
    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
    echo $TZ > /etc/timezone && \
    dpkg-reconfigure --frontend noninteractive tzdata && \
    # 设置地区
    locale-gen en_US.UTF-8 && \
    update-locale LANG=en_US.UTF-8 && \
    # 清理缓存
    rm -rf /var/lib/apt/lists/*

# 设置环境变量
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

RUN apt -y update && apt install -y \
    build-essential git m4 scons zlib1g zlib1g-dev \
    libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
    python3-dev doxygen libboost-all-dev python3-pydot \
    libpng-dev libelf-dev pkg-config pip python3-venv black python3-tk wget \
    python3-pip \
    libhdf5-dev \
    hdf5-tools \
    graphviz \
    libcapstone-dev \
    valgrind \
    libvirt-daemon-system libvirt-clients bridge-utils \

RUN apt -y update  && \
    apt -y install \
    vim \
    qemu-system \
    binutils \
    g++-aarch64-linux-gnu \
    g++-riscv64-linux-gnu \
    gcc-aarch64-linux-gnu \
    gcc-riscv64-linux-gnu \
    gcc-x86-64-linux-gnu \
    g++-x86-64-linux-gnu \
    locales \
    libsqlite3-dev \
    zlib1g-dev \
    libbz2-dev \
    autoconf \
    automake \
    build-essential \
    autotools-dev \
    bison \
    device-tree-compiler \
    flex \
    gawk \
    gperf \
    libexpat-dev \
    libgmp-dev \
    libmpc-dev \
    libmpfr-dev \
    libtool \
    libusb-1.0-0-dev \
    patchutils \
    pkg-config \
    texinfo \
    gdb \
    unzip
# RUN pip install mypy pre-commit

# 克隆 gem5（使用国内镜像）
RUN git clone https://gitee.com/mirrors/gem5.git /gem5
WORKDIR /gem5
